\bigskip
{\magonebf 6.1.1 Points (point)}

{\bf 1. Definition}

An instance of the data type $point$ is a point in the two-dimensional 
plane $\real^2$. We use $(a,b)$ to denote a point with first (or x-) 
coordinate $a$ and second (or y-) coordinate $b$.

\def\name{$point$}
\def\type{$point$}

{\bf 2. Creation}

a) \create p (double\ x,\ double\ y)

b) \create p {}


introduces a variable \var\ of type \name\ initialized to the point
$(x,y)$. Variant b) initializes \var\ to the point $(0,0)$. 


\bigskip
{\bf 3. Operations}

\smallskip
\+\cleartabs & \hskip 2.5truecm & \hskip 5truecm &\cr
\+\op double    xcoord {}
                           {returns the first coordinate of point $p$}
\smallskip
\+\op double    ycoord {}
                           {returns the second coordinate of point $p$}
\smallskip
\+\op double    distance {point\ q}
                           {returns the euclidean distance between $p$} 
\+\nop                     { and $q$.}
\smallskip
\+\op double    distance {}
                           {returns the euclidean distance between $p$}
\+\nop                     { and $(0,0)$.}
\smallskip
\+\op point   translate {vector\ v} 
                           {returns $p+v$, i.e., $p$ translated by vector}
\+\nop                     {$v$. \precond $v$.dim() = 2.}
\smallskip
\+\op point   translate {double\ \alpha,\ double\ d} {}
\+\nop                     {returns the point created by translating}
\+\nop                     {$p$ in direction $\alpha$ by distance $d$. The} 
\+\nop                     {direction is given by its angle with a}
\+\nop                     {right oriented horizontal ray.}
\smallskip
\+\op point  rotate {point\ q,\ double\ \alpha}
                        {returns the point created by a rotation of $p$}
\+\nop                  {about point $q$ by angle $\alpha$.}
\smallskip
\+\op point  rotate {double\ \alpha}
                        {returns $p$.rotate($point(0,0),\ \alpha$). }

\bigskip
{\bf 4. Operators }
\medskip
\+&$bool$     &$point$ ==  $point$     &test for equality\cr
\smallskip
\+&$bool$     &$point$ !=  $point$     &test for inequality\cr
\smallskip
\+&$point$    &$point$ +\  $vector$    &translation by vector\cr

\medskip
Input and output operators:
\medskip
\+&$ostream\&$ &$ostream << point$ &writes a point to an output stream\cr
\smallskip
\+&$istream\&$ &$istream >> point$ &reads the coordinates of a point (two doubles)\cr
\+&            &                   &from an input stream\cr

